import * as actions from '../actionTypes/'

const player = (
	state = {
		showTurtleArea: true,
		showTurtleAndResult: false,
		showDesc: false,
		showIntro: false,
		consoles: '',
		code: '',
		project: {},
	},
	action
) => {
	switch (action.type) {
		case actions.TOGGLE_TURTLE_AREA:
			return {
				...state,
				showTurtleArea: action.payload,
			}
		case actions.TOGGLE_TURTLE_AND_RESULT:
			return {
				...state,
				showTurtleAndResult: action.payload,
				consoles: '',
				showTurtleArea: true,
			}
		case actions.SET_PLAYER_ITEM:
			return {
				...state,
				code: action.code,
				project: action.payload,
			}
		case actions.HANDLE_PUT_CONSOLE:
			return {
				...state,
				consoles: state.consoles + action.payload,
			}
		case actions.TOGGLE_DESC:
			return {
				...state,
				showDesc: action.payload,
				showIntro: false,
			}
		case actions.TOGGLE_INTRO:
			return {
				...state,
				showIntro: action.payload,
				showDesc: false,
			}
		default:
			return state
	}
}

export default player



// WEBPACK FOOTER //
// ./src/reducers/player.js